<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="6" :md="12" :sm="24">
            <a-form-item label="手机号">
              <a-input-number style="width:100%" placeholder="请输入手机号" v-model="queryParam.mobile" ></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="6" :md="12" :sm="24">
            <a-form-item label="技师名称">
              <a-input placeholder="请输入技师名称" v-model="queryParam.name" ></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="6" :md="12" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons" >
              <a-button type="primary" @click="searchQuery" icon="search" >查询</a-button >
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px" >重置</a-button >
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <!-- <div class="table-operator">
      <a-button @click="crudCreate()" type="primary" icon="plus">新增</a-button>
    </div> -->
    <!-- table区域-begin -->
    <div>
      <a-table ref="table" size="middle" bordered rowKey="id" :scroll="{ x: 1300 }" :columns="columns" :dataSource="tableData" :pagination="ipagination" :loading="loading" @change="handleTableChange" >
        <!--操作-->
        <span slot="action" slot-scope="text, record" >
          <!-- <a-button type="primary" @click="handleDetail(record)">详情</a-button> -->
          <a-button type="primary" @click="crudUpdate(record)">编辑</a-button>
          <!-- <a-popconfirm title="确认删除?" ok-text="确定" cancel-text="取消" @confirm="crudDelete(record.id)">
            <a-button type="danger" icon="delete"></a-button>
          </a-popconfirm> -->
        </span>
        <!--图片预览块-->
        <span slot="imgPath" slot-scope="text, record">
          <img :src="record.avatar" width="100px" height="100px" />
        </span>
        <!--类目-->
        <span slot="catList" slot-scope="text, record">
          <a-tag class="cat_li" color="blue" v-for="(item,index) in record.skill.split(',')" :key="index">{{item}}</a-tag>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <tech-list-modal ref="updateForm" @closeModal="closeModal"></tech-list-modal>
  </a-card>
</template>

<script>
import techListModal from './modules/techListModal'
import ApiTree from "@/api/personnel/techList";
import { Slime, crud } from "@/mixins/slime";

export default {
  name: "techList",
  mixins: [Slime],
  components: {
    techListModal
  },
  data() {
    return {
      tableData: [],
      columns: [
        {
          title: "手机号",
          align: "center",
          dataIndex: "mobile",
        },
        {
          title: "名字",
          align: "center",
          dataIndex: "name",
        },
        {
          title: "头像",
          align: "center",
          dataIndex: "avatar",
          scopedSlots: { customRender: 'imgPath' },
        },
        {
          title: "职位",
          align: "center",
          dataIndex: "position",
        },
        {
          title: "从业年限",
          align: "center",
          dataIndex: "years",
        },
        {
          title: "擅长",
          align: "center",
          dataIndex: "skill",
          scopedSlots: { customRender: 'catList' },
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
      ],
    };
  },
  created() {
    crud(ApiTree);
    this.loadData();
  },
  methods: {
    // 加载表格数据
    loadData(arg) {
      this.loadDataPack(arg).then((res) => {
        let tableData = [];
        if (res.result) {
          tableData = res.result.records;
        }
        this.tableData = tableData;
      });
    },
    //详情
    handleDetail(record){
      this.$router.push({ path: '/saleDetail?id=' + record.id + '&type=1'})
    },
  },
};
</script>
<style scoped>
</style>